<template>
  <li >
    <label>
      <input type="checkbox"
             :checked="todos.done"
             @click="handleCheck(todos.id)"/>
      <span>{{ todos.title  }}</span>
    </label>
    <button class="btn btn-danger" @click="deletestr(todos.id,todos.done)">删除</button>
  </li>
</template>

<script>
export default {
  name: "MyItem",
  props:['todos','checkTodo','deleteObj'],
  methods:{
    handleCheck(id){
      //通知App组件对应的todo对象的done值取反
      this.checkTodo(id);
    },
    //如果删除的时候判断选中的为false的话 将调用父组件传递过来的函数然后父组件将判断这个列表是否删除
    deletestr(id,done){
      this.deleteObj(id,done);
    }
  }
}
</script>

<style scoped>
.btn{
  display: inline-block;
  padding: 4px 12px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.btn-danger {
  display: none;
  color: #fff;
  background-color: #da4f49;
  border: 1px solid #bd362f;
}
li:hover .btn-danger{
display: block;
}
.btn-danger:hover {
  display: block;
  color: #fff;
  background-color: #bd362f;
}
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}
li:hover .btn{
  display:block;
}
li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}

</style>